﻿function ValidateQuanHuyen() {
	var tenquanhuyen = document.getElementsByName("QuanHuyen_TenQuanHuyen").item(0);
	if (tenquanhuyen.value == "") {
		alert("Please input TenQuanHuyen");
		return false;
	}
	return true;
}

function ValidateLoaiCamNang() {
	var tenloaicamnang = document.getElementsByName("LoaiCamNang_TenLoaiCamNang").item(0);
	if (tenloaicamnang.value == "") {
		alert("Please input TenLoaiCamNang");
		return false;
	}
	return true;
}

function ValidateLoaiTinTuc() {
	var tenloaitintuc = document.getElementsByName("LoaiTinTuc_TenLoaiTinTuc").item(0);
	if (tenloaitintuc.value == "") {
		alert("Please input TenLoaiTinTuc");
		return false;
	}
	return true;
}

function ValidateLienKet() {
    var tenlienket = document.getElementsByName("LienKet_TenLienket").item(0);
    if (tenlienket.value == "") {
        alert("Please input TenLienket");
        return false;
    }
    var url = document.getElementsByName("LienKet_Url").item(0);
    if (url.value == "") {
        alert("Please input Url");
        return false;
    }
    return true;
}

function ValidateCanHo() {
	var sotang = document.getElementsByName("CanHo_SoTang").item(0);
	if (sotang.value == "") {
		alert("Please input SoTang");
		return false;
	}
	var sophongngu = document.getElementsByName("CanHo_SoPhongNgu").item(0);
	if (sophongngu.value == "") {
		alert("Please input SoPhongNgu");
		return false;
	}
	var sophongtam = document.getElementsByName("CanHo_SoPhongTam").item(0);
	if (sophongtam.value == "") {
		alert("Please input SoPhongTam");
		return false;
	}
	var namxaydung = document.getElementsByName("CanHo_NamXayDung").item(0);
	if (namxaydung.value == "") {
		alert("Please input NamXayDung");
		return false;
	}
	var huong = document.getElementsByName("CanHo_Huong").item(0);
	if (huong.value == "") {
		alert("Please input Huong");
		return false;
	}
	var loainoithat = document.getElementsByName("CanHo_LoaiNoiThat").item(0);
	if (loainoithat.value == "") {
		alert("Please input LoaiNoiThat");
		return false;
	}
	var mattien = document.getElementsByName("CanHo_MatTien").item(0);
	if (mattien.value == "") {
		alert("Please input MatTien");
		return false;
	}
	var nohau = document.getElementsByName("CanHo_NoHau").item(0);
	if (nohau.value == "") {
		alert("Please input NoHau");
		return false;
	}
	return true;
}

function ValidateTienIch() {
	var donghodien = document.getElementsByName("TienIch_DongHoDien").item(0);
	if (donghodien.value == "") {
		alert("Please input DongHoDien");
		return false;
	}
	var donghonuoc = document.getElementsByName("TienIch_DongHoNuoc").item(0);
	if (donghonuoc.value == "") {
		alert("Please input DongHoNuoc");
		return false;
	}
	var mayphatdien = document.getElementsByName("TienIch_MayPhatDien").item(0);
	if (mayphatdien.value == "") {
		alert("Please input MayPhatDien");
		return false;
	}
	var maybomnuoc = document.getElementsByName("TienIch_MayBomNuoc").item(0);
	if (maybomnuoc.value == "") {
		alert("Please input MayBomNuoc");
		return false;
	}
	var giengdong = document.getElementsByName("TienIch_GiengDong").item(0);
	if (giengdong.value == "") {
		alert("Please input GiengDong");
		return false;
	}
	return true;
}

function ValidateTienIchKhac() {
	var garaoto = document.getElementsByName("TienIchKhac_GaraOto").item(0);
	if (garaoto.value == "") {
		alert("Please input GaraOto");
		return false;
	}
	var maylanh = document.getElementsByName("TienIchKhac_MayLanh").item(0);
	if (maylanh.value == "") {
		alert("Please input MayLanh");
		return false;
	}
	var truyenhinhcap = document.getElementsByName("TienIchKhac_TruyenHinhCap").item(0);
	if (truyenhinhcap.value == "") {
		alert("Please input TruyenHinhCap");
		return false;
	}
	var sanvuon = document.getElementsByName("TienIchKhac_SanVuon").item(0);
	if (sanvuon.value == "") {
		alert("Please input SanVuon");
		return false;
	}
	var maynuocnong = document.getElementsByName("TienIchKhac_MayNuocNong").item(0);
	if (maynuocnong.value == "") {
		alert("Please input MayNuocNong");
		return false;
	}
	var internet = document.getElementsByName("TienIchKhac_Internet").item(0);
	if (internet.value == "") {
		alert("Please input Internet");
		return false;
	}
	var dienthoai = document.getElementsByName("TienIchKhac_DienThoai").item(0);
	if (dienthoai.value == "") {
		alert("Please input DienThoai");
		return false;
	}
	var chodauxehoi = document.getElementsByName("TienIchKhac_ChoDauXeHoi").item(0);
	if (chodauxehoi.value == "") {
		alert("Please input ChoDauXeHoi");
		return false;
	}
	var hoboi = document.getElementsByName("TienIchKhac_HoBoi").item(0);
	if (hoboi.value == "") {
		alert("Please input HoBoi");
		return false;
	}
	return true;
}

function ValidateVanHoaXaHoi() {
	var gantruongmaugiao = document.getElementsByName("VanHoaXaHoi_GanTruongMauGiao").item(0);
	if (gantruongmaugiao.value == "") {
		alert("Please input GanTruongMauGiao");
		return false;
	}
	var gantruongcap1 = document.getElementsByName("VanHoaXaHoi_GanTruongCap1").item(0);
	if (gantruongcap1.value == "") {
		alert("Please input GanTruongCap1");
		return false;
	}
	var gantruongcap2 = document.getElementsByName("VanHoaXaHoi_GanTruongCap2").item(0);
	if (gantruongcap2.value == "") {
		alert("Please input GanTruongCap2");
		return false;
	}
	var gantruongcap3 = document.getElementsByName("VanHoaXaHoi_GanTruongCap3").item(0);
	if (gantruongcap3.value == "") {
		alert("Please input GanTruongCap3");
		return false;
	}
	var gantruongdhcd = document.getElementsByName("VanHoaXaHoi_GanTruongDHCD").item(0);
	if (gantruongdhcd.value == "") {
		alert("Please input GanTruongDHCD");
		return false;
	}
	var gantrungtamthuongmai = document.getElementsByName("VanHoaXaHoi_GanTrungTamThuongMai").item(0);
	if (gantrungtamthuongmai.value == "") {
		alert("Please input GanTrungTamThuongMai");
		return false;
	}
	var khudantricao = document.getElementsByName("VanHoaXaHoi_KhuDanTriCao").item(0);
	if (khudantricao.value == "") {
		alert("Please input KhuDanTriCao");
		return false;
	}
	var gancho = document.getElementsByName("VanHoaXaHoi_GanCho").item(0);
	if (gancho.value == "") {
		alert("Please input GanCho");
		return false;
	}
	var gancongvien = document.getElementsByName("VanHoaXaHoi_GanCongVien").item(0);
	if (gancongvien.value == "") {
		alert("Please input GanCongVien");
		return false;
	}
	var ganbenhvien = document.getElementsByName("VanHoaXaHoi_GanBenhVien").item(0);
	if (ganbenhvien.value == "") {
		alert("Please input GanBenhVien");
		return false;
	}
	var gantrungtamgiaitri = document.getElementsByName("VanHoaXaHoi_GanTrungTamGiaiTri").item(0);
	if (gantrungtamgiaitri.value == "") {
		alert("Please input GanTrungTamGiaiTri");
		return false;
	}
	var tienkinhdoanh = document.getElementsByName("VanHoaXaHoi_TienKinhDoanh").item(0);
	if (tienkinhdoanh.value == "") {
		alert("Please input TienKinhDoanh");
		return false;
	}
	return true;
}

function ValidateLoaiGia() {
	var tenloaigia = document.getElementsByName("LoaiGia_TenLoaiGia").item(0);
	if (tenloaigia.value == "") {
		alert("Please input TenLoaiGia");
		return false;
	}
	return true;
}

function ValidateLoaiBatDongSan() {
	var tenloaibatdongsan = document.getElementsByName("LoaiBatDongSan_TenLoaiBatDongSan").item(0);
	if (tenloaibatdongsan.value == "") {
		alert("Please input TenLoaiBatDongSan");
		return false;
	}
	return true;
}

function ValidateTinhThanh() {
	var tentinhthanh = document.getElementsByName("TinhThanh_TenTinhThanh").item(0);
	if (tentinhthanh.value == "") {
		alert("Please input TenTinhThanh");
		return false;
	}
	return true;
}

function ValidateNguoiDung() {
	var username = document.getElementsByName("NguoiDung_UserName").item(0);
	if (username.value == "") {
		alert("Please input UserName");
		return false;
	}
	var password = document.getElementsByName("NguoiDung_Password").item(0);
	if (password.value == "") {
		alert("Please input Password");
		return false;
	}
	var email = document.getElementsByName("NguoiDung_Email").item(0);
	if (email.value == "") {
		alert("Please input Email");
		return false;
	}
	return true;
}

function ValidateRegister() {
    var username = document.getElementsByName("NguoiDung_UserName").item(0);
    if (username.value == "") {
        alert("Please input UserName");
        return false;
    }
    var password = document.getElementsByName("NguoiDung_Password").item(0);
    if (password.value == "") {
        alert("Please input Password");
        return false;
    }
    var re = new RegExp("^([a-zA-Z0-9!~@#$%^&*]{7,20})$");
    var m = re.exec(password.value);
    if (m == null) {
        alert("Mật khẩu phải có độ dài ít nhất 7 kí tự. Trong đó có 1 kí tự Alpha (~@#$%^&*).");
        return false;
    }
    var confirmpassword = document.getElementsByName("NguoiDung_ConfirmPassword").item(0);
    if (confirmpassword.value == "") {
        alert("Please input ConfirmPassword");
        return false;
    }
    if (password.value != confirmpassword.value) {
        alert("ConfirmPassword must be same with Password ");
        return false;
    }

    var email = document.getElementsByName("NguoiDung_Email").item(0);
    if (email.value == "") {
        alert("Please input Email");
        return false;
    }
    var hoten = document.getElementsByName("NguoiDung_HoTen").item(0);
    if (hoten.value == "") {
        alert("Please input HoTen");
        return false;
    }
    var dienthoai = document.getElementsByName("NguoiDung_DienThoai").item(0);
    if (dienthoai.value == "") {
        alert("Please input DienThoai");
        return false;
    }
    var didong = document.getElementsByName("NguoiDung_DiDong").item(0);
    if (didong.value == "") {
        alert("Please input DiDong");
        return false;
    }
    return true;
}

function ValidateLienHe() {
    var email = document.getElementsByName("HopThu_Email").item(0);
    if (email.value == "") {
        alert("Please input Email");
        return false;
    }
    var hoten = document.getElementsByName("HopThu_HoTen").item(0);
    if (hoten.value == "") {
        alert("Please input HoTen");
        return false;
    }
    var tieude = document.getElementsByName("HopThu_TieuDe").item(0);
    if (tieude.value == "") {
        alert("Please input TieuDe");
        return false;
    }
    var noidung = document.getElementsByName("HopThu_NoiDung").item(0);
    if (noidung.value == "") {
        alert("Please input NoiDung");
        return false;
    }
    return true;
}

